<template>
  <div class="right-content-main common-content">
    <div class="header">
      <div class="title">专家建议</div>
      <div class="current-box ">
        <span class="current-text">当前位置</span>
        <span class="line"></span>
        <span class="">首页</span>
        <span class="line"></span>
        <span class="">专家建议</span>
      </div>
    </div>
    <div class="content">
      <ul class="list-content">
        <li class="mask-box " @click="handleDetails(item)" v-for="(item,index) in dataList" :key="item.id">
          <div class="item">
            <div class="time_box">
              <p class="month">{{ $TOOL.dateFormat(item.updateDate, 'MM.DD') }}</p>
              <p>{{ $TOOL.dateFormat(item.updateDate, 'YYYY') }}</p>
            </div>
            <div class="info">
              <h4 class="line-2" style="height: 52px"> 【{{ item.releaseYear }}年第{{ item.termNumber }}期】{{$TOOL.richTextWithUrlsRemove(item.title)  }}</h4>
              <p class="line-2 info-sub" v-html="$TOOL.getText(item.informationContent)">
              </p>
            </div>
          </div>
        </li>
      </ul>
      <div class="df-cc">
        <el-pagination v-if="pagingData.total" background layout="prev, pager, next" :total="pagingData.total"
                       v-model:current-page="pagingData.pageNum" :page-size="pagingData.pageSize"
                       @current-change="loadPageData()"></el-pagination>
      </div>
    </div>
  </div>
</template>

<script setup>
import {homeApi} from "@/api";
import {useRouter} from "vue-router";

const pagingData = reactive({
  pageNum: 1,
  pageSize: 5,
  total: 0
})
const resultInfo = ref({})
const dataList = ref([])
onMounted(loadPageData)
async function loadPageData() {
  const res = await homeApi.expertAdviceListPage.get(pagingData)
  console.log(res)
  dataList.value = res.list
  pagingData.total = res.total
}

const router = useRouter()

function handleDetails(item) {
  router.push({
    path: '/details',
    query: {
      type: 2,
      id: item.id
    }
  })
}

</script>

<style scoped lang="scss">
.right-content-main {
  min-height: 820px;
  margin: 16px auto;
  height: 100%;
  background: #FFFFFF;

  .header {
    height: 80px;
    margin: 0 24px;
    border-bottom: 1px solid #ccc;
    display: flex;
    justify-content: space-between;

    .current-box {
      display: flex;
      align-items: center;
      color: #333333;
      font-size: 16px;

      .line {
        width: 20px;
        border-bottom: 1px solid #333;
        margin: 0 5px;
      }

      .current-text {
        color: #999;
      }

      .base-text {
        color: $base-color;
      }
    }

    .title {
      position: relative;
      height: 100%;
      padding-top: 16px;
      font-size: 26px;
      font-weight: bold;
      color: $base-color;

      &::after {
        content: '';
        width: 100%;
        border-bottom: 2px solid $base-color;
        position: absolute;
        left: 0;
        bottom: 0;
      }
    }
  }

  .content {
    margin: 24px;

    .list-content {
      li:nth-child(3) {
        --bg-color: #60B9AA;
      }

      li:nth-child(4) {
        --bg-color: #60B9AA;
      }

      li {
        background: #F5F5F5;
      }

      .item {
        width: 100%;
        padding: 16px 10px;
        margin-bottom: 20px;
        display: flex;
        position: relative;
        z-index: 2;

        &:hover {
          .time_box {
            border-bottom: 1px solid #FFFFFF;
          }

          h4 {
            color: #FFFFFF;
          }

          .info-sub{
            line-height: 24px;
            color: #fff !important;
          }
        }

        .time_box {
          color: #FFFFFF;
          width: 65px;
          height: 65px;
          display: flex;
          flex-direction: column;
          align-items: center;
          justify-content: center;
          background: var(--bg-color);
          border-bottom: 1px solid var(--bg-color);

          .month {
            font-size: 22px;
            font-weight: bold;
          }
        }

        .info {
          width: 200px;
          flex: 1;
          margin-left: 16px;
          font-size: 14px;
          text-indent: 20px;

          .info-sub {
            line-height: 24px;
            color: #666;
            font-size: 16px !important;
          }

          h4 {
            font-size: 18px;
            text-indent: 0px;
            margin-bottom: 8px;
          }

          p {
            color: #333;
          }
        }

      }
    }
  }
}
</style>
